﻿
@{
    ViewData["Title"] = "编辑用户";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
    var errmsg = TempData["errMsg"];
}
<div id="app" v-clock>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" action="@Url.Action("Edit")" method="post" style="width: 60%;">
        @Html.AntiForgeryToken()
        <el-form-item label="中文名称" prop="Name">
            <el-input v-model="ruleForm.Name" size="small" class="col-6" name="Name"></el-input>
        </el-form-item>
        <el-form-item label="英文名称" prop="EnglishName">
            <el-input v-model="ruleForm.EnglishName" size="small" class="col-6" name="EnglishName"></el-input>
        </el-form-item>
        <el-form-item label="登录账号" prop="Account">
            <el-input v-model="ruleForm.Account" size="small" class="col-6" name="Account"></el-input>
        </el-form-item>
        <el-form-item label="登录密码" prop="Passwd" v-if="ruleForm.Id=='00000000-0000-0000-0000-000000000000'">
            <el-input v-model="ruleForm.Passwd" size="small" class="col-6" type="password" name="Passwd"></el-input>
        </el-form-item>
        <el-form-item label="邮箱" prop="Email">
            <el-input v-model="ruleForm.Email" size="small" class="col-6" name="Email"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="MobilePhone">
            <el-input v-model="ruleForm.MobilePhone" size="small" class="col-6" name="MobilePhone"></el-input>
        </el-form-item>
        <el-form-item label="是否允许登录" prop="IsLogin">
            <el-checkbox v-model="ruleForm.IsLogin">允许登录</el-checkbox>
        </el-form-item>
        <el-form-item label="是否普通账号" prop="IsNormal">
            <el-checkbox v-model="ruleForm.IsNormal">普通账号</el-checkbox>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @@click="submitForm('ruleForm')" size="small">保存</el-button>
            <el-button @@click="resetForm('ruleForm')" size="small">重置</el-button>
            <el-button icon="el-icon-back" size="small" @@click="funBack">返回 用户管理</el-button>
        </el-form-item>
        <input type="hidden" v-model="ruleForm.Id" name="Id"/>
        <input type="hidden" v-model="ruleForm.CreateAt" name="CreateAt"/>
        <input type="hidden" v-model="ruleForm.CreateName" name="CreateName"/>
        <input type="hidden" v-model="ruleForm.CreateId" name="CreateId"/>
        <input type="hidden" v-model="ruleForm.UpdateAt" name="UpdateAt"/>
        <input type="hidden" v-model="ruleForm.UpdateName" name="UpdateName"/>
        <input type="hidden" v-model="ruleForm.UpdateId" name="UpdateId"/>
        <input type="hidden" v-model="ruleForm.IsDel" name="IsDel"/>
        <input type="hidden" v-model="ruleForm.IsLogin" name="IsLogin"/>
        <input type="hidden" v-model="ruleForm.IsNormal" name="IsNormal"/>
    </el-form>
</div>
@section Scripts
    {
    <script type="text/javascript">
        @if (errmsg!=null&&!string.IsNullOrEmpty(errmsg.ToString()))
        {
            //系统异常信息 输出
          @:$(function() { @(Html.Raw(errmsg)); });
        }
        
        new Vue({
            el: "#app",
            data:function () {
                return {
                    ruleForm: @Html.Raw(ViewBag.model),
                    rules: {
                        Name: [
                            { required: true, message: '请输入中文名称', trigger: 'blur' }
                        ],
                        Account: [
                            { required: true, message: '请输入登录账号', trigger: 'change' }
                        ]
                    }
                };
            },
            methods: {
                submitForm: function(formName) {
                    this.$refs[formName].validate(function(valid) {
                        if (valid) {
                            $("form").eq(0).submit();
                        } else {
                            return false;
                        }
                    });
                },
                resetForm: function(formName) {
                    this.$refs[formName].resetFields();
                },
                funBack: function() {
                    window.history.go(-1);
                }
            }
        })
    </script>
}
